package work5;
public class  ExceptionExample{
    public static void main(String[] args) {
        People people = new People();
        
        for (int i =0; i < 128; i++){
            try{
                people.printLetter((char) i);
            }catch (NoLowerLetter n){
                n.print();
            }
        }
        System.out.println();
        for (int i = 0; i < 128; i++){
            try {
                people.printDigit((char) i);
            }catch (NoDigit n){
                n.print();
            }
        }
        System.out.println("\n0501刘冰");
    }
}
class  NoLowerLetter extends Throwable {
    public void print(){
        System.out.printf("%c",'#');
    }
}
class NoDigit extends Throwable{
    public void print(){
        System.out.printf("%c", '*');
    }
}
class  People{
    void printLetter(char c) throws NoLowerLetter {
        if (c >= 'a'&& c <= 'z' || c >= 'A'&& c <= 'Z'){
            System.out.print(c);
        }else{
            NoLowerLetter noLowerLetter = new NoLowerLetter();
            throw noLowerLetter;
        }
    }
    void printDigit(char c) throws  NoDigit{
        if(c >='0' && c <= '9'){
            System.out.print(c);
        }else{
            NoDigit noDigit = new NoDigit();
            throw noDigit;
        }
    }
}
